package com.bibimaya.auto.mapper.dao.utils;

import com.bibimaya.auto.mapper.dao.constant.Const;

/**
 * DeleteSqlUtil
 * Created by lijianwei
 */
public class DeleteSqlUtil {

    public static String deleteSql(Class entityClass){
        return deleteSql(EntityMap.newInstance(entityClass, null), null);
    }

    public static String deleteSql(EntityMap entityMap) {
        return deleteSql(entityMap, null);
    }

    public static String deleteSql(EntityMap entityMap, String whereSqlAppend) {
        StringBuffer sql = new StringBuffer("<script>");
        sql.append(Const.NEW_LINE);
        sql.append(Const.TAB).append("delete from ").append(entityMap.getTable());
        sql.append(Const.NEW_LINE);
        sql.append(WhereSqlUtil.whereSql(entityMap, Const.TAB, whereSqlAppend));
        sql.append("</script>");
        return sql.toString();
    }

}
